import Vue from 'vue'
import App from './App.vue'
import store from './store'
import router from './router'
import axios from 'axios'

// 挂载axios
Vue.prototype.$axios = axios

// element-ui
import ElementUI from 'element-ui';
Vue.use(ElementUI);
import '../theme/index.css'
import 'element-ui/lib/theme-chalk/index.css';

// 初始化&图标样式
import '@/assets/scss/base.scss'
import '@/assets/fonts/iconfont.css'

// vue-layer
import layer from 'vue-layer'
import 'vue-layer/lib/vue-layer.css';
Vue.prototype.$layer = layer(Vue, {
  msgtime: 1.5
});

// ajax请求
import http from '@/assets/api/https'
import ApiList from '@/assets/api/api'
import ptApiList from '@/assets/api/pt-api'

Vue.prototype.$http = http;
Vue.prototype.$ApiList = ApiList;
Vue.prototype.$ptApiList = ptApiList;

import judgePower from '@/utils/judgePower'
Vue.prototype.$judgePower = judgePower;

// 复制内容到剪切板
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)

// 百度Echart
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

// 百度地图
import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
  ak: '1f2bb828810a06de3cacdcf31efb6c67'
})

// 视频播放插件
import VideoPlayer from 'vue-video-player'
require('video.js/dist/video-js.css')
require('vue-video-player/src/custom-theme.css')
Vue.use(VideoPlayer)

// 富文本编辑器
import VueUeditorWrap from 'vue-ueditor-wrap'
Vue.component('vue-ueditor-wrap', VueUeditorWrap)

// 音频播放插件
import VueAudio from 'vue-audio-better'
Vue.use(VueAudio)

// 全局挂载组件
import HeadTitle from '@/components/headTitle.vue' //页面标题头部
import HeadBackTitle from '@/components/headBackTitle.vue' //页面返回上级头部
import RefreshButton from '@/components/refresh-button' //页面刷新组件
import SearchView from '@/components/SearchView'; //搜索组件
Vue.component('HeadTitle', HeadTitle);
Vue.component('HeadBackTitle', HeadBackTitle);
Vue.component('RefreshButton', RefreshButton);
Vue.component('SearchView', SearchView);

Vue.config.productionTip = false

// 监听路由变化改变网页title并返回顶部
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    if(to.name==='maitou'){
      document.title = to.meta.title
    }else{
      document.title = to.meta.title + ' - 家具大师后台管理系统'
    }
  }
  next()
})

router.afterEach((to,from,next) => {
  window.scrollTo(0, 0);
})

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')